from django.db import models
from django.template.defaultfilters import title


class Config(models.Model):
    name = models.CharField(unique=True, verbose_name='配置名', max_length=100)
    model = models.CharField(verbose_name='模型名', max_length=100)
    base_url = models.CharField(max_length=100)
    api_key = models.CharField(max_length=100)
    timeout = models.IntegerField(verbose_name='超时时间', default=300)

    def __str__(self):
        return self.name


# Create your models here.
class Translation(models.Model):
    task_name = models.CharField(verbose_name='任务名称', max_length=100)
    config = models.ForeignKey(Config, verbose_name='AI模型配置', on_delete=models.CASCADE, null=True)
    language = models.CharField(verbose_name='目标语言', max_length=100, default='中文')
    target_file_type = models.CharField(verbose_name='目标文件格式', max_length=100, default='PDF',choices=[('PDF', 'PDF'), ('markdown', 'markdown')])
    book = models.FileField(verbose_name='原始书籍路径', upload_to='static/books/%Y%m%d', default=1)
    result_file = models.FileField(verbose_name='翻译结果路径', upload_to='static/results/%Y%m%d', null=True, blank=True)
    status = models.CharField(verbose_name='翻译状态', max_length=100, default='等待翻译')
